package com.youjiang.meeting.interceptor;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import net.sf.json.JSONObject;

/**
 * <p>
 * Title: CoustomExceptionResolver
 * </p> 
 * <p>
 * Description:TODO
 * </p> 
 * <p>
 * Company: YouJiang
 * </p> 
 *
 * @author feng
 * @date 2016年12月8日 下午2:44:10
 * @version 1.0
 */
public class CoustomExceptionResolver implements HandlerExceptionResolver{
	
	@Override
	public ModelAndView resolveException(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2,
			Exception arg3) {
		JSONObject json=new JSONObject();
		
		json.put("code", 0);
		json.put("msg", "未知错误");
		try {
			arg1.setCharacterEncoding("UTF-8");
			arg1.getWriter().write(json.toString());
			arg1.getWriter().close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

}
